package com.wy2.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wy2.entity.Follow;
import com.wy2.service.FollowService;
import com.wy2.util.FenyeUtil;

@RequestMapping("/follow")
@RestController
@CrossOrigin
public class FollowController {
	
	@Autowired
	private FollowService fs;
	/***
	 * 分页查询
	 * @param fenye
	 * @param follow
	 * @return
	 */
	@GetMapping
	public FenyeUtil<Follow> getAll(FenyeUtil<Follow> fenye,Follow follow){
		fenye.setT(follow);
		fenye = fs.getAll(fenye);
		return fenye;
	}
	/**
	 * 添加
	 * @param f
	 * @return
	 */
	@RequestMapping("/addfol")
	public Integer addFol(Follow f) {
		//使用时间工具
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		//创建一个时间对象
		String time = sdf.format(new Date());
		//写入数据库
		f.setFtime(time);
		
		return fs.addFol(f);
	}
	/**
	 * 修改
	 * @param f
	 * @return
	 */
	@RequestMapping("/upd")
	public Integer updFol(Follow f) {
		return fs.updFol(f);
		
	}
	/**
	 * 删除
	 * @param fid
	 * @return
	 */
	@RequestMapping("/del")
	public Integer delFol(Integer fid) {
		return fs.delFol(fid);
	}
	
	
}
